// Copyright 2021 Datafuse Labs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::pipelines::PipelineBuilder;
use crate::sessions::QueryContext;

impl PipelineBuilder {
    // Create a new pipeline builder with the same context as the current builder
    pub fn create_sub_pipeline_builder(&self) -> PipelineBuilder {
        let sub_context = QueryContext::create_from(self.ctx.as_ref());
        let mut sub_builder =
            PipelineBuilder::create(self.func_ctx.clone(), self.settings.clone(), sub_context);
        sub_builder.hash_join_states = self.hash_join_states.clone();
        sub_builder
    }
}
